Data compression method for efficiently compressing data based on data periodicity

ABSTRACT

This invention provides a data compression method for efficiently compressing data based on data periodicity. To compress an input data stream and output the encoded stream, encoded input data is stored in a moving window having a predetermined size. A partial sequence starting from a given position (entry) in the moving window is compared with a data sequence to be encoded by a plurality of comparators. An entry having a maximum matching length is found by a matching finder in comparison by the plurality of comparators. When matching is found by the matching finder, a pair of offsets up to the entry and a matching length (offsets and matching length) are encoded by a matching code generator. The number of comparators is smaller than the size of the moving window, and some of offsets near offset 0 (0 indicates including no offset), offsets near offset L, offsets near offset 2L, offsets near offsets 3L, . . . are used as entries.

TECHNICAL FIELD

The present invention generally relates to a data compression methodand, more particularly, to a data compression method of efficientlycompressing particularly image data using a data compression techniquebased on a dictionary-based method that is represented by LZ77 and LZ78.

BACKGROUND ART

Current data compression methods of compressing data by adictionary-based method are derived from Abraham Lempel and Jacob Ziv,“A Universal Algorithm for Sequential Data Compression”, IEEETransaction on Information Theory (1977).

This method is generally called a Lempel-Ziv encoding slide dictionarymethod or LZ77 method.

The LZ77 method is introduced in, e.g., Seiji Munakata, “Ziv-Lempel DataCompression Method”, Information Processing, Vol. 26, No. 1 (1985).

The LZ77 algorithm is a method of segmenting data to be encoded into astream having a maximum matching length from an arbitrary position of apast data stream, and encoding the segmented stream as a copy of thepast stream.

More specifically, as shown in FIG. 3, the LZ77 algorithm uses a movingwindow storing encoded input data and a prefetch buffer storing data tobe encoded, and collates all partial sequences of a data sequence in themoving window with those in the prefetch buffer to obtain a matchingpartial sequence having a maximum length in the moving window.

To designate a partial sequence having a maximum length in the movingwindow, a combination of “the start position of a partial sequencehaving a maximum length”, “a matching length”, and “a next symbol whichcancels matching” are encoded.

An encoded data sequence in the prefetch buffer is moved to the movingwindow, and a new data sequence corresponding to the encoded datasequence is input to the prefetch buffer.

The same processing is repeated to decompose data into partial sequencesand encode the partial sequences.

Many improvements of this basic data compression technique have beenproposed.

For example, there is an LZSS encoding method of setting a flag foridentifying whether data is an encoded code or raw data and when theencoded data is longer than the raw data, encoding the raw data (T. C.Bell, “Better OPM/L Text Compression”, IEEE Transaction Commun., Vol.COM-34, No. 12, Dec. (1986)).

Another reference is M. Nelson, “Data Compression Handbook: SecondEdition”, Toppan (1996), ISBN4-8101-8605-9.

In resent years, OA systems (scanners, printers, digital copyingmachines, and the like) are becoming popular, and higher speeds andhigher resolutions are required.

These systems must process large-amount image data at a high speed, sothat they must reduce the processing data amount by compressing data ata high speed and high compression ratio.

The conventional data compression technique includes standard methodssuch as MMR and JBIG. However, MMR tends to decrease the compressionratio for a fine image.

JBIG, which attains almost the highest compression ratio, basicallyprocesses data in units of pixels, is limited in an increase in speed,and thus cannot be employed in high-speed systems.

The above dictionary-based compression method basically processes datain units of bytes, can attain a much higher speed than JBIG, can keepthe compression ratio for a fine image in comparison with MMR, and issuitable for high-speed, high-resolution OA systems.

In encoding, however, a conventional LZ77-based data compressionapparatus must compare a data sequence to be encoded with data sequencesstarting from all positions in the moving window in order to obtain amatching partial data sequence having a maximum length in the movingwindow.

More specifically, as shown in FIG. 3, a data sequence to be encoded iscompared with a data sequence starting from the position of offset 1 inthe moving window, a data sequence starting from the position of offset2, . . . , and a data sequence starting from the position of offset n (nis the size of the moving window), thereby finding an offset having amaximum matching length.

Hardware which implements this at a high speed is disclosed in U.S. Pat.No. 5,003,307.

As shown in FIG. 4, this hardware implements a moving window having amoving window size of n by n shift registers SR1 to SRn, andparallel-processes n comparisons using n comparators CMP1 to CMPn.

This method can advantageously process one data by one clock, butrequires comparators equal in number to the moving window size andbecomes difficult to realize for a larger moving window size.

For example, for a moving window size of 2 kB, this conventional methodrequires 2 k comparators.

DISCLOSURE OF INVENTION

The present invention has been made in consideration of the abovesituation, and has as its object to provide an improvement of anapparatus and method for comparing dictionary data with input data toencode matching data and decoding encoded compressed data in a dataprocessing apparatus and data processing method and, more particularly,to provide an LZ77-based data compression method with a small number ofcomparators based on image data periodicity.

It is another object of the present invention to provide a datacompression method for performing pre-processing of rearranging databased on image data periodicity so as to allow data having high matchingpossibility to come close to each other.

To achieve the above objects, according to one aspect of the presentinvention, there is provided a data compression method for compressingan input data stream and outputting the encoded stream, comprising thesteps of:

storing encoded input data in a moving window having a predeterminedsize,

comparing a partial sequence starting from a given position (entry) inthe moving window with a data sequence to be encoded by a plurality ofcomparators,

finding an entry having a maximum matching length by a matching finderin comparison by the plurality of comparators, and

encoding a pair of offsets up to the entry and a matching length(offsets and matching length) by a matching code generator when matchingis found by the matching finder,

wherein the number of comparators is smaller than the size of the movingwindow, and some of offsets near offset 0 (0 indicates including nooffset), offsets near offset L, offsets near offset 2L, offsets nearoffsets 3L, . . . are used as entries.

To achieve the above objects, according to another aspect of the presentinvention, there is provided a data compression method for compressingan input data stream and outputting the encoded stream, comprising thesteps of:

rearranging by a pre-processing unit a byte order of the input datastream:

0, 1, 2, 3, . . . , L, L+1, L+2, . . . , 2L, 2L+1, 2L+2, . . . into

0, L, 2L, . . . , nL, 1, l+1, 2L+1, . . . , nL+1, 2, L+2, 2L+2, . . . ,nL+2, . . . (n=1, 2, . . . ), and

compressing the input data stream rearranged by the pre-processing unitand outputting the encoded stream from a compression type compressionapparatus main body.

To achieve the above objects, according to still another aspect of thepresent invention, there is provided a data compression method forcompressing an input data stream and outputting the encoded stream,comprising the steps of: rearranging by a pre-processing unit an orderof m-bit bytes (m=p×q; p is an integer not less than 1 and q is aninteger not less than 2) of the input data stream:

First Line: 0, 1, 2, . . . , Second Line: L, L+1, L+2, . . . , . . . . .. qth Line: (q−1)L, (q−1)L+1, (q−1)L+2, . . . , qL−1 into a new firstbyte made up of m bits: 0 : b(0), . . . , 0 : b(p−1), L : b(0), . . . ,L : b(p−1), . . . . . . (q−1)L : b(0), . . . , (q−1)L : b(p−1) a newsecond byte made up of m bits: 0 : b(0), . . . , 0 : b(2p−1), L : b(0),. . . , L : b(2p−1), . . . . . . (q−1)L : b(0), . . . , (q−1)L : b(2p−1). . . . . . a new qth byte made up of m bits: 0 : b((q−1)p), . . . , 0 :b(qp−1), L : b((q−1)p), . . . , L : b(q2p−1), . . . . . . (q−1)L :b((q−1)p), . . . , (q−1)L : b(q2p−1), a new (q+1)th byte made up of mbits: 1 : b(0), . . . , 1 : b(p−1), L+1 : b(0), . . . , L+1 : b(p−1), .. . . . . (q−1)L+1 : b(0), . . . , (q−1)L+1 : b(p−1), . . . . . . a new(q+2)th byte made up of m bits: 1 : b(p), . . . , 1 : b(2p−1), L+1 :b(p), . . . , L+1 : b(2p−1), . . . . . . (q−1)L+1 : b(p), . . . ,(q−1)L+1 : b(2p−1), . . . . . . a new 2qth byte made up of m bits: 1 :b((q−1)p), . . . , 1 : b(qp−1), L+1 : b((q−1)p), . . . , L+1 : b(q2p−1),. . . . . . (q−1)L+1 : b((q−1)p), . . . , (q−1)L+1 : b(q2p−1), . . . . ..

(note that the first, second, . . . , mth bits in a byte arerespectively represented by b(0), b(1), . . . , b(m−1), and left andright sides of “0:b(0)” respectively represent the byte order of aninput stream and a bit in the byte), and

compressing the input data stream rearranged by the pre-processing unitand outputting the encoded stream by a compression type compressionapparatus main body.

To achieve the above objects, according to still another aspect of thepresent invention, there is provided a data compression method forcompressing an input data stream and outputting the encoded stream,comprising the steps of:

rearranging by a pre-processing unit a byte order of an input datastream:

0, 1, 2, 3, . . . , L, . . . (L is a rearrangement cycle, L = p × q; pand q are integers not less than 2) into 0, p, 2p, . . . , (q−1)p 1,p+1, 2p+1, . . . , (q−1)p+1 2, p+2, 2p+2, . . . , (q−1)p+2 . . . . . .p−1, p+1−1, 2p+p−1, . . . , (q−1)p+p−1, and

compressing the input data stream rearranged by the pre-processing unitand outputting the encoded stream by a compression apparatus main body.

To achieve the above objects, according to still another aspect of thepresent invention, there is provided a data compression method forcompressing an input data stream and outputting the encoded stream,wherein comprising the steps of:

rearranging by a pre-processing unit a byte order of an input datastream:

0, 1, 2, 3, . . . , L, . . . into

0, 2, 4, . . . , L−2, 1, 3, 5, . . . L−1, . . . (L is an even number) or

0, 2, 4, . . . , L−1, 1, 3, 5, . . . , L−2, . . . (L is an odd number),and

compressing the input data stream rearranged by the pre-processing unitand outputting the encoded stream by a compression type compressionapparatus

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a view for explaining the principle of the first embodimentaccording to the present invention.

FIG. 2 is a diagram for explaining the arrangement of the firstembodiment according to the present invention.

FIG. 3 is a view for explaining the principle of a conventional LZ77compression apparatus.

FIG. 4 is a diagram for explaining the arrangement of the conventionalLZ77 compression apparatus.

FIG. 5 is a table for explaining offsets to be compared by comparatorsCM1 to CMP16 in the present invention.

FIGS. 6A to 6D are views for explaining other selection examples ofcomparison positions in the first embodiment according to the presentinvention.

FIGS. 7A and 7B are views for explaining other selection examples ofcomparison positions in the first embodiment according to the presentinvention.

FIGS. 8A and 8B are views for explaining other selection examples ofcomparison positions in the first embodiment according to the presentinvention.

FIGS. 9A and 9B are views for explaining other selection examples ofcomparison positions in the first embodiment according to the presentinvention.

FIG. 10 is a view for explaining the principle of the second embodimentaccording to the present invention.

FIG. 11 is a diagram for explaining the arrangement of the secondembodiment according to the present invention.

FIGS. 12A and 12B are views for explaining other selection examples ofcomparison positions in the second embodiment according to the presentinvention.

FIG. 13 is a block diagram for explaining the arrangement of the thirdembodiment according to the present invention.

FIGS. 14A to 14C are views for explaining rearrangement method 1 in thethird embodiment according to the present invention.

FIGS. 15A and 15B are views for explaining rearrangement method 2 in thethird embodiment according to the present invention.

FIGS. 16A and 16B are views for explaining rearrangement method 3 in thethird embodiment according to the present invention.

FIG. 17 is a block diagram for explaining operation of a pre-processing(line) buffer (controller) 101 b in a pre-processing unit 101 in thethird embodiment according to the present invention.

FIGS. 18A and 18B are views for explaining rearrangement method 1 in thefourth embodiment according to the present invention.

FIGS. 19A and 19B are views for explaining rearrangement method 2 in thefourth embodiment according to the present invention.

FIGS. 20A and 20B are views for explaining rearrangement method 3 in thefourth embodiment according to the present invention.

FIG. 21 is a block diagram for explaining operation of a pre-processing(line) buffer (controller) 101 b in a pre-processing unit 101 in thefourth embodiment according to the present invention.

FIGS. 22A to 22C are views for explaining a rearrangement method in thefifth embodiment according to the present invention.

FIG. 23 is a block diagram for explaining operation of a pre-processing(line) buffer (controller) 101 b in a pre-processing unit 101 in thefifth embodiment according to the present invention.

FIGS. 24A and 24B are views for explaining pre-processing of thepre-processing unit in the fourth embodiment according to the presentinvention.

FIG. 25 is a view for explaining pre-processing of the pre-processingunit in the fourth embodiment according to the present invention.

BEST MODE OF CARRYING OUT THE INVENTION

Embodiments of the present invention will be described below withreference to the several views of the accompanying drawing.

As described in Technical Field, U.S. Pat. No. 5,003,307 discloses anLZ77-based data compression apparatus implemented by hardware at a highspeed.

In this reference, a moving window having a moving window size of n isimplemented by n shift registers, and n comparisons are processedparallel by n comparators.

This method can advantageously process one data by one clock, butrequires comparators equal in number to the moving window size andbecomes difficult to realize for a larger moving window size.

The first embodiment of the present invention, therefore, easilyrealizes LZ77-based hardware by comparing a data sequence to be encodedwith not data sequences starting from all positions in the moving windowbut data sequences starting from positions having high matchingpossibility.

For example, if the number of comparison positions is about 16 or 32,comparisons can be satisfactorily processed parallel by comparatorsequal in number to the comparison positions.

However, if the number of comparison positions is simply decreased, thematching possibility may decrease to decrease the compression ratio.

For this reason, the first embodiment selects comparison positions basedon image data periodicity.

That is, a data sequence to be encoded is compared with not all partialsequences in the moving window but partial sequences starting from datapositions having high matching possibility on the basis of the imagedata periodicity.

The principle of the first embodiment according to the present inventionwill be described with reference to FIG. 1.

In the first embodiment, the data unit is a byte.

Considering two-dimensional locality of image data, bytes most similarto a certain byte to be encoded are ones at upper, lower, right, andleft positions around the target byte.

In general raster scan in an image data input order from an upper leftposition to a lower right position, right and lower bytes adjacent to abyte to be encoded have not been input yet and have not entered themoving window yet.

Thus, a byte to be encoded cannot be compared with right and loweradjacent bytes. A left byte adjacent to a byte to be encoded is thelatest data input previously in the input order, and has entered theposition of offset 1 in the moving window.

An upper adjacent byte has entered the position of offset L in themoving window for an input image data line length (width) of L bytes.

In this case, the moving window size must be L or more.

A conventional LZ-based CODEC ignores input periodicity even if theinput is image data, and searches for a matching point to only the leftfor a byte to be encoded.

The first embodiment selects the upper adjacent position and itsperipheral positions as comparison points for a byte to be encoded inaddition to the left position.

Accordingly, the moving window includes bytes (bytes □ in FIG. 1) notserving as comparison points between bytes (bytes ▪ in FIG. 1) servingas comparison points at two ends.

In data sequence portions (bytes ⋄ and ==== . . . in FIG. 1), a byte ⋄is a head byte.

Decreasing the number of comparison positions in this way can shortenthe offset code.

For example, for a moving window size of 2 kB, 2 k codes are required asoffsets in the prior art, but only 16 codes are required as offsets inthe example of FIG. 1. When a simple code is selected, the offset codelength is 11 bits in the prior art but is as short as 4 bits in thepresent invention.

FIG. 2 is a block diagram showing the arrangement of the firstembodiment according to the present invention.

The first embodiment comprises (L+5)B shift registers SR forimplementing a moving window with a predetermined size when L representsthe length of one line of image data to be compressed, 16 comparatorsCMP1 to CMP16, and a matching position detection circuit (maximum lengthdetermination unit) DET, in addition to a line memory and memorycontroller (neither is shown).

The first embodiment adopts comparison positions (offsets 1, 2, . . . ,5, L−5, L−4, . . . , L−1, L, L+1, . . . , L+5) shown in FIG. 1.

The line memory suffices to be a line buffer having a size of L−6 for aninput data line length of L bytes.

While storing a data sequence (current line data) to be encoded in thisline buffer, a data sequence (previous line data) before one line issent to an encoder according to the first embodiment via apre-processing unit (not shown) as follows.

In parallel with this, the current line data itself is sent to theencoder according to the first embodiment via the pre-processing unit(not shown) as follows.

In the encoder according to the first embodiment, previous line data isinput from the pre-processing unit to five shift registers SR, andoutputs from the respective shift registers are used as comparisonposition data of offsets 1 to 5.

Line data ahead by offset L−6 is input from the pre-processing unit to11 shift registers SR, and outputs from the respective shift registersare used as comparison position data of offsets L−5 to L+5.

Each of the total of 16 comparison position data is input to oneterminal of a corresponding one of the 16 comparators CMP1 to CMP16 andcompared with the head byte (byte ⋄ in FIG. 1) of a data sequence to beencoded that is commonly input to the other terminal of each of thecomparators CMP1 to CMP16.

FIG. 5 shows offsets compared by the comparators CMP1 to CMP16.

Operation of the comparators CMP1 to CMP16 and matching positiondetection circuit (maximum length determination unit) DET will beexplained.

Each of the comparators CMP1 to CMP16 has a matchingcontinuation/matching end flag. The comparator performs comparison everyclock preset to the matching continuation mode, and if nonmatching isfound, sets the flag to the matching end mode to wait for nextpresetting.

First, the flags of the comparators CMP1 to CMP16 are preset, and amatching length counter in the matching position detection circuit(maximum length determination unit) DET is also initialized to 0.

The comparators and matching position detection circuit (maximum lengthdetermination unit) DET operate as follows every clock.

If all the flags change to the matching end mode at a matching lengthcount of 0 (this indicates that data at the encoding position (byte ⋄ inFIG. 1) does not match data at any comparison position (byte ▪ in FIG.1)), data at the encoding position is sent to a literal code generatorin the matching position detection circuit (maximum length determinationunit) DET to instruct generation of a literal code.

While at least one comparator is in the matching continuation mode, thematching length counter is counted up every clock.

Whether at least one comparator is in the matching continuation mode isdetermined by an OR circuit in the matching position detection circuit(maximum length determination unit) DET.

If matching ends at a matching length count of 1 or more, the matchingposition detection circuit (maximum length determination unit) DETgenerates a matching code.

At this time, the matching length counter sends a comparator number inthe matching continuation mode and a matching length to a matching codegenerator in the matching position detection circuit (maximum lengthdetermination unit) DET.

When a plurality of comparators simultaneously end the matchingcontinuation mode, one closest to comparator 1 is adopted.

This can be realized by using a priority encoder in the matchingposition detection circuit (maximum length determination unit) DET.

When the matching position detection circuit (maximum lengthdetermination unit) DET instructs generation of a literal code ormatching code, the encoder presets the flags of the comparators CMP1 toCMP16 and initializes the matching length counter to 0, therebycontinuing processing from the first operation.

The literal code generator adds a literal code marker to a head byte tobe encoded and outputs the resultant data.

The matching code generator receives a comparator number and matchinglength, outputs a matching code made up of an offset code and matchinglength code in accordance with an encoding table, and in additionoutputs the length of the matching code (the length of the offsetcode+the length of the matching length code).

The offset code, offset code length, matching length code, and length ofthe matching length code are prepared in a ROM for the matching codegenerator in the matching position detection circuit (maximum lengthdetermination unit) DET.

In packet packing, a code and code length are input from the literalcode generator or matching code generator and packed.

Note that the first embodiment can adopt various comparison positions asshown in FIGS. 6A to 6D, 7A, 7B, 8A, 8B, 9A, and 9B in addition to thecomparison positions shown in FIG. 1 (offsets 1, 2, . . . , 5, L−5, L−4,. . . , L−1, L, L+1, . . . , L+5).

The second embodiment of the present invention will be described.

The second embodiment selects comparison points every other byte, andinput image data is multivalued data which represents one pixel by twobytes.

Of the two bytes, the first byte represents luminance information, andthe second byte represents color difference information.

When a given byte is compared with another byte, as shown in FIG. 10, aluminance byte and color difference byte have low matching possibility,and luminance bytes or color difference bytes have high matchingpossibility.

In other words, it is not effective to select points apart by an oddnumber of points as comparison points.

In this case, therefore, comparison points are selected not every byte,unlike the first embodiment, but every other byte, thereby moreeffectively compressing data.

That is, comparison positions are selected as shown in FIGS. 12A and12B.

FIG. 11 is a block diagram showing the arrangement of the secondembodiment according to the present invention.

The second embodiment comprises (L+10)B shift registers SR forimplementing a moving window when L represents the length of one line ofimage data to be compressed, 16 comparators CMP1 to CMP16, and amatching position detection circuit (maximum length determination unit)DET, in addition to a line memory and memory controller (neither isshown).

The second embodiment adopts comparison positions (offsets 1, 2, . . . ,10, L−10, L−9, . . . , L−1, L, L+1, . . . , L+10) shown in FIG. 12A.

The line memory suffices to be a line buffer having a size of L−11 foran input data line length of L bytes.

While storing a data sequence (current line data) to be encoded in thisline buffer, a data sequence (previous line data) before one line issent to an encoder according to the second embodiment via apre-processing unit (not shown) as follows.

In parallel with this, the current line data itself is sent to theencoder according to the second embodiment via the pre-processing unit(not shown) in as follows.

In the encoder according to the second embodiment, previous line data isinput from the pre-processing unit to every other ones of 10 shiftregisters SR, and outputs from the respective shift registers are usedas comparison position data of offsets 2, 4, 6, 8, and 10.

Line data ahead by offset L−11 is input from the pre-processing unit toevery other ones of 21 shift registers SR, and outputs from therespective shift registers are used as comparison position data ofoffsets L−10, L−8, . . . , L−2, L, L+2, . . . , L+8, L+10.

Each of the total of 16 comparison position data is input to oneterminal of a corresponding one of the 16 comparators CMP1 to CMP16 andcompared with the head byte (byte ⋄ in FIG. 12A) of a data sequence tobe encoded that is commonly input to the other terminal of each of thecomparators CMP1 to CMP16.

Note that offsets compared by the comparators CMP1 to CMP16 are shown inFIG. 5.

The remaining arrangement and operation of the second embodiment are thesame as in the first embodiment.

The third embodiment of the present invention will be described.

FIG. 13 is a block diagram showing the arrangement of the thirdembodiment according to the present invention.

In the third embodiment, input image data is rearranged and then encodedby an encoder main body 102 by performing subscanning in a predetermineddirection by a pre-processing unit 101 having an address rearrangementunit 101 a and pre-processing buffer 101 b so as to efficiently executeencoding by an encoder according to the third embodiment of the presentinvention or other encoders.

For example, if image data having 1-bit pixels is raster-input, one byteas an LZ processing unit is made up of 8 pixels (8 bits) successive inthe main scanning direction (horizontal direction).

When a certain byte of the image data is compared with a left adjacentbyte, each bit serving as each pixel is compared with a pixel apart by 8pixels.

When a certain byte is compared with an upper adjacent byte (at the sameposition on the previous line), each pixel is compared with a pixelapart by one pixel.

In this way, the general method excessively gives priority to an upperadjacent byte.

Hence, rearrangement of input image data according to the thirdembodiment is done to make comparison pixel intervals in the horizontaland vertical directions equal, thereby obtaining a higher datacompression ratio.

More specifically, rearrangement methods 1, 2, and 3 (to be describedbelow) are done as a method of vertically subscanning a plurality oflines without rearranging bits in a byte.

In rearrangement method 1, two lines are vertically subscanned withoutrearranging bits in a byte, as shown in FIGS. 14A to 14C.

In rearrangement method 2, four lines are vertically subscanned withoutrearranging bits in a byte, as shown in FIGS. 15A and 15B.

In rearrangement method 3, eight lines are vertically subscanned withoutrearranging bits in a byte, as shown in FIGS. 16A and 16B.

A layout example and operation of rearrangement method 1 will beexplained.

FIGS. 14A to 14C show input orders when the length of one line is 100bytes.

Input image data is input to the pre-processing unit 101 in a byte order(1, 2, 3, . . . , 100 on the first line, 101, 102, . . . , 200 on thesecond line, and 201, . . . on the third line) by normal scanning(raster scanning).

These bytes are rearranged by reading out them by the buffer 101 b inthe pre-processing unit 101 in a byte order (1, 3, 5, . . . , 199 on thefirst line, 2, 4, 6, . . . , 200 on the second line, and 201, . . . onthe third line) as shown in FIG. 14B.

Outputs from the pre-processing unit 101 are rearranged in a byte order(1, 2, 3, . . . , 200 on the first line, and 201, . . . on the secondline) as shown in FIG. 14C.

Operation of the pre-processing (line) buffer (controller) 101 b in thepre-processing unit 101 will be explained with reference to FIG. 17.

The line buffer controller 101b comprises two banks of 2-line buffers b1and b2, an input address generator b3, and an output address generatorb4.

Addresses to the line buffers b1 and b2 are controlled as follows.

When input addresses are 1, 2, 3, . . . , 100, 101, 102, . . . , 200 (a100-byte line), output addresses are 1, 101, 2, 102, . . . , 100, 200.

The banks are switched as follows.

(1) Bank 1 receives the bytes of lines 1 and 2, and bank 2 is at rest.

(2) Bank 1 reads out the bytes of lines 1 and 2 in the memory, andrearranges and sends them to the encoder. Bank 2 receives the bytes oflines 3 and 4.

(3) Bank 1 receives the bytes of lines 5 and 6. Bank 2 reads out thebytes of lines 3 and 4, and rearranges and sends them to the encoder.

(4) The same processing is repeated.

As for rearrangement methods 2 and 3 as shown in FIGS. 15A, 15B, 16A,and 16B, only the readout order from the pre-processing buffer 101 b andthe pre-processing output order are illustrated because thepre-processing input order is common to the respective methods.

The fourth embodiment of the present invention will be described.

The fourth embodiment of the present invention sends data to an encoderafter performing different rearrangement from the third embodiment withthe same arrangement as the third embodiment shown in FIG. 13.

More specifically, the fourth embodiment of the present invention adoptsrearrangement method 1 of rearranging bits into a rectangular block of4×2 bits (the numbers of bits in the horizontal and verticaldirections), as shown in FIGS. 18A and 18B, rearrangement method 2 ofrearranging bits into a 2×4-bit rectangular block, as shown in FIGS. 19Aand 19B, and rearrangement method 3 of rearranging bits into a 1×8-bitrectangular block, as shown in FIGS. 20A and 20B.

As for rearrangement methods 1, 2, and 3 as shown in FIGS. 18A, 18B,19A, 19B, 20A, and 20B, only the readout order from a pre-processingbuffer 101 b and the pre-processing output order are illustrated becausethe pre-processing input order is common to the respective methods ofthe third embodiment.

Operation of the pre-processing (line) buffer (controller) 101 b in apre-processing unit 101 will be explained with reference to FIG. 21.

In the fourth embodiment, the line buffer controller 101 b shown in FIG.13 comprises two banks of 8-bit×2-line buffers b1 and b2, an inputaddress generator b3, an output address generator b4, 4-byte×2-lineshift registers c1 and c2, and a serial-to-parallel converter d1.

Addresses to the line buffers b1 and b2 are controlled as follows.

When input addresses are 1, 2, 3, . . . , 100, 101, 102, . . . , 200 (a100-byte line), output addresses are 1, 101, 2, 102, . . . , 199, 200.

The fifth embodiment of the present invention will be described below.

The fifth embodiment of the present invention performs differentrearrangement from the third embodiment with the same arrangement as thethird embodiment shown in FIG. 13, and then sends the results to anencoder.

More specifically, the fifth embodiment of the present inventionarranges luminance bytes and color difference bytes, respectively, inthe first and second halves of a line within the line, as shown in FIGS.22A to 22C.

As shown in FIG. 22A, image data is input to a pre-processing unit 101by normal scanning (raster scanning).

FIGS. 22A to 22C show input orders when the length of one line is 100bytes.

The image data is rearranged by reading out it by a buffer 101 b in thepre-processing unit 101, as shown in FIG. 22B.

Outputs from the pre-processing unit 101 are arranged as shown in FIG.22C.

Operation of the pre-processing (line) buffer (controller) 101 b in thepre-processing unit 101 will be explained with reference to FIG. 23.

In the fifth embodiment, the line buffer controller 101 b shown in FIG.13 comprises two banks of 8-bit×2-line buffers b1 and b2, an inputaddress generator b3, and an output address generator b4.

Addresses to the line buffers b1 and b2 are controlled as follows.

When input addresses are 1, 2, 3, . . . , 100 (a 100-byte line), outputaddresses are 1, 51, 2, 52, . . . , 50, 100.

The respective embodiments in the present invention will be summarized.

(First Embodiment)

The encoder main body according to the first embodiment comprises n linebuffers, uses peripheral positions on a current line, previous line,second previous line, . . . as entries, and preferentially assigns shortoffset codes to identical positions on a previous line, second previousline,

More specifically, a conventional LZ77-based data compression apparatusrequires many comparators in order to obtain a matching partial sequencehaving a maximum length in a moving window. To the contrary, the firstembodiment is based on image data periodicity. Data to be encoded hashigh matching possibility with data at an identical position orperipheral positions on a previous line, an identical position orperipheral positions on the second previous line, an identical positionor peripheral positions on the third previous line, .Thus, some ofpositions (0 represents including no offset) near offset 0 having highmatching possibility, positions near offset L (L is an image line lengthand is externally supplied to the compression apparatus), positions nearoffset 2L, positions near offset 3L, . . . are used as entries insteadof comparison with all entries in the moving window. As a result, a highdata compression ratio can be obtained with a small number ofcomparators.

(Second Embodiment)

The encoder main body according to the second embodiment is differentfrom the encoder main body according to the first embodiment in thatentries are set every n bytes for n-byte blocks. Particularly for a dotimage, entries are set to positions apart by a dot interval×n (n=1, 2, .. . ) If a block length÷bytes has a remainder, entries are set everyleast common multiple.

If the dot interval is not an integer multiple of bytes, entries are setto positions apart by a least common multiple×n.

In the first embodiment, when image data is an image of 2-byte pixels,data to be encoded has high matching possibility with entries at offsets2, 4, . . . , and low matching possibility with entries at offsets 1, 3,As for a previous line and second previous line, data to be encodedsimilarly has high matching possibility with entries at offsets L±2,L±4, . . . , and low matching possibility with entries at offsets L±1,L±3, . . . .

Hence, the second embodiment can attain a high data compression ratiowith a small number of comparators by using, as entries, offsets M, 2M,. . . (M is the byte length of one pixel) near offset 0, offsets L±M,L±2M, . . . near offset L, and offsets 2L±M, 2L±2M, . . . near offset2L. When the interval between dots in the main scanning direction or theinterval between peaks of a centralized dither is, e.g., 2 bytes inimage data of a dot image or centralized dither image in addition toimage data of 2-byte pixels, data to be encoded has high matchingpossibility with entries apart by the interval between dots in the mainscanning direction or the interval between peaks of a centralizeddither. Also in this case, a high data compression ratio can be attainedwith a small number of comparators by using, as entries, offsets M, 2M,. . . (M is the byte length of the interval between dots in the mainscanning direction or the interval between peaks of a centralizeddither) near offset 0, offsets L±M, L±2M, . . . near offset L, andoffsets 2L±M, 2L±2M, . . . near offset 2L.

The byte length of one pixel, or the byte length of the interval betweendots in the main scanning direction or the interval between peaks of acentralized dither may not be an integer multiple of one byte. In thiscase, letting m be the bit length of one pixel, or the bit length of theinterval between dots in the main scanning direction or the intervalbetween peaks of a centralized dither, and M be the least commonmultiple of m and 8, data to be encoded has high matching possibilitywith entries apart by M, 2M, . . . .

For this reason, a high data compression ratio can be attained with asmall number of comparators by using, as entries, offsets M, 2M, . . .(M is the least common multiple of m and 8) near offset 0, offsets L±M,L±2M, . . . near offset L, and offsets 2L±M, 2L±2M, near offset 2L.

(Third Embodiment)

The third embodiment adopts pre-processing of rearranging by n linebuffers the byte order of an input data stream:

0, 1, 2, 3, . . . , L, L+1, L+2, . . . , 2L, 2L+1, 2L+2, . . .

into

0, L, 2L, . . . , nL, 1, L+1, 2L+1, . . . , nL+1, 2, L+2, 2L+2, . . . ,nL+2, . . . (n=1, 2, . . . )

The line buffers can be eliminated by performing the same operation insimple pre-processing in addition to address generation.

More specifically, the LZ-based compression apparatus can increase thecompression ratio by rearranging input data and concentrating datahaving high matching possibility.

In the third embodiment, if input data is image data, given data isconsidered to match data adjacent in the subscanning direction at higherpossibility than data adjacent in the main scanning direction. Thus, thedata compression ratio can be increased by rearranging the byte order ofan input data stream in the above manner by a pre-processing unit andinputting the data to the compression apparatus main body.

(Fourth Embodiment)

The fourth embodiment rearranges image data into n×(8÷n) rectangularblocks (4 bits in the main scanning direction×4 bits in the subscanningdirection, 2×4, 1×8, and the like) by n line buffers.

The line buffers can be eliminated by performing the same operation insimple pre-processing in addition to address generation.

Similarly to the third embodiment, the fourth embodiment can increasethe compression ratio by rearranging image data into successivetwo-dimensional rectangular blocks and inputting them into thecompression apparatus main body.

Note that a pre-processing unit 101 according to the fourth embodimentincludes the followings.

(1) As shown in FIG. 24A, a pre-processing unit rearranges the order ofm-bit bytes of an input data stream:

First Line: 0, 1, 2, . . . ,

Second Line: L, L+1, L+2, . . . ,

into

0, 1, 2, 3, 4, 5, . . .

in a 2(m/2)-byte order.

(2) As shown in FIG. 24B, a pre-processing unit rearranges the order ofm-bit bytes of an input data stream:

First Line: 0, 1, 2, . . . ,

Second Line: 2L, 2L+1, 2L+2, . . . ,

Third Line: 3L, 3L+1, 3L+2, . . . ,

Fourth Line: 4L, 4L+1, 4L+2, . . . , into

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, . . .

in a 4(m/4)-byte order.

(3) As shown in FIG. 25, a pre-processing unit rearranges the order ofm-bit bytes of an input data stream:

First Line: 0, 1, 2, . . . ,

Second Line: 2L, 2L+1, 2L+2, . . . ,

Third Line: 3L, 3L+1, 3L+2, . . . ,

Fourth Line: 4L, 4L+1, 4L+2, . . . ,

Fifth Line: 5L, 5L+1, 5L+2, . . . ,

Sixth Line: 6L, 6L+1, 6L+2, . . . ,

Seventh Line: 7L, 7L+1, 7L+2, . . . ,

Eighth Line: 8L, 8L+1, 8L+2, . . . , into

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, . . .

in an 8(m/8)-byte order.

Further, a pre-processing unit having a generalized one of the abovearrangement rearranges the order of m-bit bytes (m=p×q; p is an integerof 1 or more and q is an integer of 2 or more) of an input data stream:

First Line: 0, 1, 2, . . . , Second Line: L, L+1, L+2, . . . , . . . . .. qth Line: (q−1)L, (q−1)L+1, (q−1)L+2, . . . , qL−1 into a new firstbyte made up of m bits: 0 : b(0), . . . , 0 : b(p−1), L : b(0), . . . ,L : b(p−1), . . . . . . (q−1)L : b(0), . . . , (q−1)L : b(p−1) a newsecond byte made up of m bits: 0 : b(0), . . . , 0 : b(2p−1), L : b(0),. . . , L : b(2p−1), . . . . . . (q−1)L : b(0), . . . , (q−1)L : b(2p−1). . . . . . a new qth byte made up of m bits: 0 : b((q−1)p), . . . , 0 :b(qp−1), L : b((q−1)p), . . . , L : b(q2p−1), . . . . . . (q−1)L :b((q−1)p), . . . , (q−1)L : b(q2p−1), a new (q+1)th byte made up of mbits: 1 : b(0), . . . , 1 : b(p−1), L+1 : b(0), . . . , L+1 : b(p−1), .. . . . . (q−1)L+1 : b(0), . . . , (q−1)L+1 : b(p−1), . . . . . . a new(q+2)th byte made up of m bits: 1 : b(p), . . . , 1 : b(2p−1), L+1 :b(p), . . . , L+1 : b(2p−1), . . . . . . (q−1)L+1 : b(p), . . . ,(q−1)L+1 : b(2p−1), . . . . . . a new 2qth byte made up of m bits: 1 :b((q−1)p), . . . , 1 : b(qp−1), L+1 : b((q−1)p), . . . , L+1 : b(q2p−1),. . . . . . (q−1)L+1 : b((q−1)p), . . . , (q−1)L+1 : b(q2p−1), . . . . ..

(note that the first, second, . . . , mth bits within a byte arerespectively represented by b(0), b(1), . . . , b(m-1), and the left andright sides of “0:b(0)” respectively represent the byte order of aninput stream and a bit in the byte).

As described above, this pre-processing includes

8-bit bytes for p=4 and q=2,

8-bit bytes for p=2 and q=4,

8-bit bytes for p=1 and q=8,

In addition, a pre-processing unit rearranges the byte order of an inputdata stream:

0, 1, 2, 3, . . . , L, . . . (L is a rearrangement cycle, L = p × q; pand q are integers of 2 or more) into 0, p, 2p, . . . , (q−1)p 1, p+1,2p+1, . . . , (q−1)p+1 2, p+2, 2p+2, . . . , (q−1)p+2 . . . . . . p−1,p+1−1, 2p+p−1, . . . , (q−1)p+p−1

(Fifth Embodiment)

For n-byte blocks, a pre-processing unit rearranges the luminance, colordifference, luminance, color difference, luminance, color difference, .. . into the luminance, luminance, luminance, . . . , color difference,color difference, color difference, . . . within a line.

The line buffers can be eliminated by performing the same operation insimple pre-processing in addition to address generation.

More specifically, the fifth embodiment can increase the datacompression ratio by rearranging image data of pixels each made up of aplurality of bytes into a sequence of the first bytes of respectivepixels, a sequence of the second bytes of respective pixels, . . . , andallowing data having high matching possibility to come close to eachother.

As has been described in detail, the present invention relates to animprovement of an apparatus and method for comparing dictionary datawith input data to encode matching data, and decoding encoded compresseddata in a data processing apparatus and data processing method and, moreparticularly, to provide an LZ77-based data compression method with asmall number of comparators based on image data periodicity.

Moreover, the present invention can provide a data compression method ofperforming pre-processing of rearranging data based on image dataperiodicity so as to bring data having high matching possibility to comeclose to each other.

What is claimed is:
 1. A data compression method for compressing aninput data stream and outputting the encoded stream, comprising thesteps of: storing encoded input data in a moving window having apredetermined size; comparing a partial sequence starting from a givenposition (entry) in the moving window with a data sequence to be encodedby a plurality of comparators; finding an entry having a maximummatching length by a matching finder in comparison by the plurality ofcomparators; and encoding a pair of offsets up to the entry and amatching length (offsets and matching length) by a matching codegenerator when matching is found by the matching finder, wherein thenumber of comparators is smaller than the size of the moving window, andsome of offsets near offset 0 (0 indicates including no offset), offsetsnear offset L, offsets near offset 2L, offsets near offsets 3L, . . .are used as entries.
 2. A data compression method according to claim 1,characterized in that L which defines an offset is an externallysupplied parameter.
 3. A data compression method according to claim 1,wherein when the input data is image data, L which defines an offset isa line length of the input image data.
 4. A data compression methodaccording to claim 1, wherein L which defines an offset is an externallysupplied parameter, and offsets M, 2M, . . . (M is an externallysupplied parameter; M<L), offsets L±M, L±2M, . . . , and offsets 2L±M,2L±2M, . . . are respectively employed as offsets near offset 0, offsetsnear offset L, and offsets near offset 2L.
 5. A data compression methodaccording to claim 1, wherein when the input data is image data ofpixels each having n bytes (n: an integer not less than 2), L whichdefines an offset is an externally supplied parameter, and offsets M,2M, . . . (M=n; M<L), offsets L+M, L±2M, . . . , and offsets 2L±M,2L±2M, are respectively employed as offsets near offset 0, offsets nearoffset L, and offsets near offset 2L.
 6. A data compression methodaccording to claim 1, wherein when the input data is a dot image orcentralized dither image having an interval of n bytes between dots in amain scanning direction or between peaks in a centralized dither, Lwhich defines an offset is a line length of the input image data, andoffsets M, 2M, . . . (M=n; M<L), offsets L±M, L±2M, . . . , and offsets2L±M, 2L±2M, . . . are respectively employed as offsets near offset 0,offsets near offset L, and offsets near offset 2L.
 7. A data compressionmethod according to claim 1, wherein when the input data is image dataof pixels each having m bits (m is a natural number which cannot bedivided by 8), L which defines an offset is an externally suppliedparameter, and offsets M, 2M, . . . (M=a least common multiple of m and8; M<L), offsets L±M, L±2M, . . . , and offsets 2L±M, 2L±2M, . . . arerespectively employed as offsets near offset 0, offsets near offset L,and offsets near offset 2L.
 8. A data compression method according toclaim 1, wherein when the input data is a dot image or centralizeddither image having an interval of m bits (m is a natural number whichcannot be divided by 8) between dots in a main scanning direction orbetween peaks in a centralized dither, L which defines an offset is aline length of the input image data, and offsets M, 2M, . . . (M=a leastcommon multiple of m and 8; M<L), offsets L±M, L±2M, . . . , and offsets2L±M, 2L±2M, . . . are respectively employed as offsets near offset 0,offsets near offset L, and offsets near offset 2L.
 9. A data compressionmethod for compressing an input data stream and outputting the encodedstream, wherein comprising the steps of: rearranging by a pre-processingunit a byte order of the input data stream: 0, 1, 2, 3, . . . , L, L+1,L+2, . . . , 2L, 2L+1, 2L+2, . . . into 0, L, 2L, . . . , nL, 1, L+1,2L+1, . . . , nL+1, 2, L+2, 2L+2, . . . , nL+2, . . . (n=1, 2, . . . );and compressing the input data stream rearranged by the pre-processingunit, by a compression apparatus main body and outputting the encodedstream, wherein the step of outputting the encoded stream by thecompression apparatus main body comprises the steps of: storing encodedinput data to a moving window having a predetermined size; comparing apartial sequence starting from a given position (entry) in the movingwindow with a data sequence to be encoded by a plurality of comparators;finding an entry having a maximum matching length by a matching finderin comparison by the plurality of comparators; and encoding a pair ofoffsets up to the entry and a matching length (offsets and matchinglength) by a matching code generator when matching is found by thematching finder, wherein the number of comparators is smaller than thesize of the moving window, and some of offsets near offset 0 (0indicates including no offset), offsets near offset L (L is anexternally supplied parameter), offsets near offset 2L, offsets nearoffsets 3L, . . . are used as entries.
 10. A data compression methodaccording to claim 9, wherein when the input data is image data, L whichdefines an offset is a line length of the input image data.
 11. A datacompression method according to claim 9, wherein when the input data isimage data, L which defines an offset is a line length of the inputimage data, and when a transfer source of the input data is a memory, areadout order (order to supply addresses) is set to a head of a 0thline, a head of a first line, . . . , a head of an nth line, the next ofthe 0th line, the next of the first line, . . . , the next of the nthline, and processing is done by a pre-processing unit corresponding to areadout unit.
 12. A data compression method for compressing an inputdata stream and outputting the encoded stream, wherein comprising thesteps of: rearranging by a pre-processing unit a byte order of the inputdata stream: 0, 1, 2, 3, . . . L, L+1, L+2, . . . 2L, 2L+1, 2L+2, . . .into 0, L, 2L, . . . nL, 1, L+1, 2L+1, . . . , nL+1, 2, L+2, 2L+2, . . ., nL+2, . . . (n=1, 2, . . . ); and compressing the input data streamrearranged by the pre-processing unit, by a compression apparatus mainbody and outputting the encoded stream, wherein the step of outputtingthe encoded stream by the compression apparatus main body comprises thesteps of: storing encoded input data to a moving window having apredetermined size; comparing a partial sequence starting from a givenposition (entry) in the moving window with a data sequence to be encodedby a plurality of comparators; finding an entry having a maximummatching length by a matching finder in comparison by the plurality ofcomparators; and encoding a pair of offsets up to the entry and amatching length (offsets and matching length) by a matching codegenerator when matching is found by the matching finder, wherein thenumber of comparators is smaller than the size of the moving window, andsome of offsets near offset 0 (0 indicates including no offset), offsetsnear offset nL, offsets near offset 2nL, offsets near offsets 3nL, . . .are used as entries.
 13. A data compression method according to claim12, wherein when the input data is image data, L which defines an offsetis a line length of the input image data.
 14. A data compression methodaccording to claim 12, wherein when the input data is image data, Lwhich defines an offset is a line length of the input image data, andwhen a transfer source of the input data is a memory, a readout order(order to supply addresses) is set to a head of a 0^(th) line, a head ofa first line, . . . , a head of an nth line, the next of the 0^(th)line, the next of the first line, . . . , the next of the nth line, . .. and processing is done by a pre-processing unit corresponding to areadout unit.
 15. A data compression method for compressing an inputdata stream and outputting the encoded stream, comprising the steps of:storing encoded input data in a moving window having a predeterminedsize; comparing a partial sequence starting from a given position(entry) in the moving window with a data sequence to be encoded by aplurality of comparators; finding an entry having a maximum matchinglength by a matching finder in comparison by the plurality ofcomparators; encoding a pair of offsets up to the entry and a matchinglength (offsets and matching length) by a matching code generator whenmatching is found by the matching finder, wherein the number ofcomparators is smaller than the size of the moving window, and at leastone of offsets near offset 0 (0 indicates including no offset) and nearoffset L are used as entries; rearranging by a pre-processing unit abyte order of an input data stream: 0, 1, 2, 3, . . . , L, . . . (L is arearrangement cycle, L=p×q, p and q are integers not less than 2) into0, p, 2p, . . . , (q−1)p 1, p+1, 2p+1, . . . , (q−1)p+1 2, p+2, 2p+2, .. . , (q−1)p+2 . . . . . . p−1, p+[1]p−1, 2p+p−1, . . . , (q−1)p+p−1;and

compressing the input data stream rearranged by the pre-processing unitand outputting the encoded stream by a compression apparatus main body.16. A data compression method for compressing an input data stream andoutputting the encoded stream, comprising the steps of: storing encodedinput data in a moving window having a predetermined size; comparing apartial sequence starting from a given position (entry) in the movingwindow with a data sequence to be encoded by a plurality of comparators;finding an entry having a maximum matching length by a matching finderin comparison by the plurality of comparators; encoding a pair ofoffsets up to the entry and a matching length (offsets and matchinglength) by a matching code generator when matching is found by thematching finder, wherein the number of comparators is smaller than thesize of the moving window, and at least one of offsets near offset 0 (0indicates including no offset) and near offset L are used as entries;rearranging by a pre-processing unit a byte order of an input datastream: 0, 1, 2, 3, . . . , L, into 0, 2, 4, . . . , L−2, 1, 3, 5, . . ., L−1, . . . (L is an even number) or 0, 2, 4, . . . , L−1, 1, 3, 5, . .. , L−2, . . . (L is an odd number); and compressing the input datastream rearranged by the pre-processing unit and outputting the encodedstream by a compression type compression apparatus.
 17. A datacompression method for compressing an input data stream and outputtingthe encoded stream, comprising the steps of: storing encoded input datato a moving window having a predetermined size; comparing a partialsequence starting from a given position (entry) in the moving windowwith a data sequence to be encoded by a plurality of comparators;finding an entry having a maximum matching length by a matching finderin comparison by the plurality of comparators; and encoding a pair ofoffsets up to the entry and a matching length (offsets and matchinglength) by a matching code generator when matching is found by thematching finder, wherein the number of comparators is smaller than thesize of the moving window, and at least one of offsets near offset 0 (0indicates including no offset) and near offset L are used as entries.18. A data compression method according to claim 17, characterized inthat L which defines an offset is an externally supplied parameter. 19.A data compression method according to claim 17, wherein when the inputdata is image data, L which defines an offset is a line length of theinput image data.
 20. A data compression method according to claim 17,wherein L which defines an offset is an externally supplied parameter,and offsets M, where M is an externally supplied parameter and M<L, andL±M are respectively employed as offsets near offset 0, and near offsetL.
 21. A data compression method according to claim 17, wherein when theinput data is image data of pixels each having n bytes, n being aninteger not less than 2, L which defines an offset is an externallysupplied parameter, and offsets M, where M=n and M<L, and L±M arerespectively employed as offsets near offset 0 and near offset L.
 22. Adata compression method according to claim 17, wherein when the inputdata is a dot image or centralized dither image having an interval of nbytes between dots in a main scanning direction or between peaks in acentralized dither, L which defines an offset is a line length of theinput image data, and offsets M and L±M are respectively employed asoffsets near offset 0 and near offset L.
 23. A data compression methodaccording to claim 17, wherein when the input data is image data ofpixels each having m bits, m being a natural number which cannot bedivided by 8, L which defines an offset is an externally suppliedparameter, and offsets M, where M=a least common multiple of m and 8 andM<L, and L±M are respectively employed as offsets near offset 0 and nearoffset L.
 24. A data compression method according to claim 17, whereinwhen the input data is a dot image or centralized dither image having aninterval of m bits, where m is a natural number which cannot be dividedby 8, between dots in a main scanning direction or between peaks in acentralized dither, L which defines an offset is a line length of theinput image data, and offsets M, wherein M=a least common multiple of mand 8 and M<L, and L±M are respectively employed as offsets near offset0 and near offset L.
 25. A data compression method for compressing aninput data stream and outputting the encoded stream, comprising thesteps of: storing encoded input data in a moving window having apredetermined size; comparing a partial sequence starting from a givenposition (entry) in the moving window with a data sequence to be encodedby a plurality of comparators; finding an entry having a maximummatching length by a matching finder in comparison by the plurality ofcomparators; encoding a pair of offsets up to the entry and a matchinglength (offsets and matching length) by a matching code generator whenmatching is found by the matching finder, wherein the number ofcomparators is smaller than the size of the moving window, and at leastone of offsets near offset 0 (0 indicates including no offset) and nearoffset L are used as entries; rearranging by a pre-processing unit anorder of m-bit bytes (m=p×q; p is an integer not less than 1 and q is aninteger not less than 2) of the input data stream: First Line: 0, 1, 2,. . . , Second Line: L, L+1, L+2, . . . , . . . . . . qth Line: (q−1)L,(q−1)L+1, (q−1)L+2, . . . , qL−1 into a new first byte made up of mbits: 0 : b(0), . . . , 0 : b(p−1), L : b(0), . . . , L : b(p−1), . . .. . . (q−1)L : b(0), . . . , (q−1)L : b(p−1) a new second byte made upof m bits: 0 : b(0), . . . , 0 : b(2p−1), L : b(0), . . . , L : b(2p−1),. . . . . . (q−1)L : b(0), . . . , (q−1)L : b(2p−1) . . . . . . a newqth byte made up of m bits: 0 : b((q−1)p), . . . , 0 : b(qp−1), L :b((q−1)p), . . . , L : b(q2p−1), . . . . . . (q−1)L : b((q−1)p), . . . ,(q−1)L : b(q2p−1) a new (q+1)th byte made up of m bits: 1 : b(0), . . ., 1 : b(p−1), L+1 : b(0), . . . , L+1 : b(p−1), . . . . . . (q−1)L+1 :b(0), . . . , (q−1)L+1 : b(p−1) . . . . . . a new (q+2)th byte made upof m bits: 1 : b(p), . . . , 1 : b(2p−1), L+1 : b(p), . . . , L+1 :b(2p−1), . . . . . . (q−1)L+1 : b(p), . . . , (q−1)L+1 : b(2p−1) . . . .. . a new 2qth byte made up of m bits: 1 : b((q−1)p), . . . , 1 :b(qp−1), L+1 : b((q−1)p), . . . , L+1 : b(q2p−1), . . . . . . (q−1)L+1 :b((q−1)p), . . . , (q−1)L+1 : b(q2p−1) . . . . . .

wherein the first, second, . . . , mth bits within a byte arerespectively represented by b(0), b(1), . . . , b(m−1), and left andright sides of “0: b(0)” respectively represent the byte order of aninput stream and a bit in the byte; and compressing the input datastream rearranged by the pre-processing unit and outputting the encodedstream by a compression type compression apparatus main body.